package com.example.demo.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;

/**
 * @ClassName TestFileInputStream
 * @Description TODO
 * @Author hly
 * @Date 2018\11\27 0027 11:25
 */
public class TestFileInputStream {

    public static void main(String[] args) {
//        FileInputStream in = null;
        FileReader in = null;
        FileOutputStream out = null;
        try {
//            in = new FileInputStream("F:\\mayun\\springboot-parent-demo\\sb-some\\src\\main\\java\\com\\example\\demo\\SbSomeApplication.java");
            in = new FileReader("F:\\\\mayun\\\\springboot-parent-demo\\\\sb-some\\\\src\\\\main\\\\java\\\\com\\\\example\\\\demo\\\\SbSomeApplication.java");
            out = new FileOutputStream("C:\\a.txt");

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        try {
            int b = 0;
            int num = 0;
            while ((b = in.read())!=-1) {
                System.out.print((char) b);
                out.write(b);
                num++;
            }
            System.out.println("一共打印字节数："+num);
            in.close();
            out.close();
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
